<?php
/**
 * @file
 * Download Monitor - Allows you to trace file downloads. Just place the direct link
 * to the file on the web, and specify the extensions of files you want to trace in the GUI.
 * It creates interactive chart and records downloads for today, yesterday, this week,
 * last week, this month, last month and total.
 * Requires writable .htaccess file of Apache Web server in Joomla root folder.
 * @package download-monitor
 * @version 1.0
 * @revision @REVISION@
 * @license http://www.gnu.org/licenses/gpl-3.0.txt     GNU General Public License v3
 * @copyright (C) 2012 by CodeGravity.com - All rights reserved!
 * @website http://www.codegravity.com
 */

if($task=='add_file')
{
    if (isset($_POST['Submit']) &&  $_POST['Submit']=="Add")
    {
        $filepathnamename = trim(mysql_escape_string($_POST['filepathname']));

        $filepathquery_add = sprintf("insert into #__download_monitor_paths (dname) values ('%s')", mysql_escape_string($filepathnamename));
        $db->setQuery($filepathquery_add);
        $db->query();
        header("location: index.php?option=com_download-monitor");
    }

    ?>
<form action="" method="post" name="addfilepathform" onsubmit="return check_add_filepath();">
    <table width="83%" border="0" cellpadding="3" cellspacing="0" class="table">
        <tr>
            <td colspan="2" class="Subtitle">Add File/Path </td>
        </tr>
        <tr>
            <td height="23" colspan="2" align="left" style='color: red'><b>Warning:</b> always backup your .htaccess file before adding new extension or path! Do not add "php" as monitored extension. <br/>Be also careful with adding png/jpg, the download count will be increased once someone opens your page which contains images with this extension.<br/><br/></td>
        </tr>
        <tr>
            <td width="31%">
                <div align="right">File/Path Name<font color="#FF0000"> *</font>                    </div>                  </td>
            <td width="69%" align="left">
                <input name="filepathname" type="text" size="50" value="">                  </td>
        </tr>
        <tr class="title">
            <td height="20" colspan="2">
                <div align="center">
                    <input name="Submit" type="submit" class="button" value="Add">
                    <input name="Submit" type="button" class="button" value="Back" onclick="window.location.href='index.php?option=com_download-monitor'">
                </div>                  </td>
        </tr>
    </table>
    <br>
</form>
<?php
}
?>